function strToArr(s) {
  return s.split("`")
}

function arrToStr(a) {
  var s = a[0]
  for (var i = 1; i < a.length; i++) {
    s += "`" + a[i]
  }
  return s
}

function validMoney(money) {
  var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
  if (reg.test(money)) {
    return true;
  } else {
    return false;
  };
}

function timeInMsgList(time) {
  var date = new Date()
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()
  var myYear = time.substr(0,4)
  var myMonth = time.substr(5,2)
  var myDay = time.substr(8,2)
  var myHour = time.substr(11,2)
  var myMin = time.substr(14,2)
  if(parseInt(myYear)==year && parseInt(myMonth)==month && parseInt(myDay)==day) {
    return myHour+":"+myMin
  }
  else if(parseInt(myYear)==year && parseInt(myMonth)==month && parseInt(myDay)==day-1) {
    return "昨天"
  }
  else {
    return myYear + "-" + myMonth + "-" + myDay
  }
}

module.exports = {
  strToArr,
  arrToStr,
  validMoney,
  timeInMsgList,
}